package com.cn.activitiNSV.controller;

import java.util.List;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.cn.activitiNSV.service.UserService;




@Controller
@RequestMapping("/")
@CrossOrigin
public class UserController {

	@Autowired
	private UserService userservice;

	@SuppressWarnings("rawtypes")
	@RequestMapping("home")
	@ResponseBody
    public String home() {
		List<Map> list = userservice.selectUser();
		for(Map map : list) {
			System.out.print(map.get("id"));
			System.out.print("\n"+map.get("title"));
			System.out.println();
		}

        return "public/templates/NewFile";
    }

	@RequestMapping("home1")
	public String index(HttpServletRequest request, HttpServletResponse resp) {
		request.getSession().setAttribute("hello", 123);
//		resp.setHeader("Access-Control-Allow-Origin", "*");
		return "NewFile";
	}
}
